var validate;

(function () {
    var get, fields, validateField, result;
    
    validate = function (form) {
        result = true;
        if (get('driver').value != 'PoSQL') {
            validateField('dbServer');
            validateField('dbUser');
            validateField('dbPassword');
        }
        validateField('dbName');
        validateField('timezone');
        validateField('language');
        validateField('imageBackground');
        validateField('imageQuality');
        return result;
    };
    
    validateField = function (id) {
        if (!get(id).value) {
            get(id).className = 'invalid';
            result = false;
        }
    };
    
    get = function (id) {
        return document.getElementById(id);
    };
}());
